package bank.mvc;

import framework.account.IAccount;
import framework.mvc.ACustomButton;
import framework.mvc.AFincoView;
import framework.mvc.FincoContext;

import java.util.Map;

public class ReportButton extends ACustomButton {

    public ReportButton(AFincoView view) {
        super(view, "Report");
    }

    @Override
    public void fireClick() {
        int rowSelectedIndex = view.getRowSelectedIndex();
        if (rowSelectedIndex == -1)
            return;

        IAccount account = FincoContext.getFinco().getSelectedAccount(rowSelectedIndex);
        Map<String, String> report = FincoContext.getFinco().getAccountData(account.getAccountNo());
        ReportDialog dialog = new ReportDialog(view, report);
        dialog.setVisible(true);
    }
}
